import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProfitMarginSettingVO, ProfitMarginSettingForm, ProfitMarginSettingQuery } from '@/api/order/profitMarginSetting/types';

/**
 * 查询毛利设置列表
 * @param query
 * @returns {*}
 */

export const listProfitMarginSetting = (query?: ProfitMarginSettingQuery): AxiosPromise<ProfitMarginSettingVO[]> => {
  return request({
    url: '/order/profitMarginSetting/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询毛利设置详细
 * @param id
 */
export const getProfitMarginSetting = (id: string | number): AxiosPromise<ProfitMarginSettingVO> => {
  return request({
    url: '/order/profitMarginSetting/' + id,
    method: 'get'
  });
};

/**
 * 新增毛利设置
 * @param data
 */
export const addProfitMarginSetting = (data: ProfitMarginSettingForm) => {
  return request({
    url: '/order/profitMarginSetting',
    method: 'post',
    data: data
  });
};

/**
 * 修改毛利设置
 * @param data
 */
export const updateProfitMarginSetting = (data: ProfitMarginSettingForm) => {
  return request({
    url: '/order/profitMarginSetting',
    method: 'put',
    data: data
  });
};

/**
 * 删除毛利设置
 * @param id
 */
export const delProfitMarginSetting = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/profitMarginSetting/' + id,
    method: 'delete'
  });
};
